#include <stdio.h>
#include <string.h>

typedef struct Node
{
	int x, y, step;
}Node;

Node queue[70];
int head, tail;
int sx, sy, ex, ey;
int movex[]={-2, -2, -1, -1, +1, +1, +2, +2};
int movey[]={-1, +1, -2, +2, -2, +2, -1, +1};
char flag[9][9];
char s1[3], s2[3];

void wfs() {
	Node now, next;
	// put first data into queue
	queue[0].x = sx;
	queue[0].y = sy;
	queue[0].step = 0;
	head = 0;
	tail = 1;
	// search
	memset(flag, 0, sizeof(flag));
	flag[sx][sy] = 1;
	while ( head < tail )
	{
		now = queue[head];
		if (now.x == ex && now.y == ey)
		{
			break;
		}
		for ( int i=0; i<8 ; ++i)
		{
			next.x = now.x + movex[i];
			next.y = now.y + movey[i];
			next.step = now.step + 1;
				
			if ( next.x >= 1 && next.x <= 8 && next.y >= 1 && next.y <= 8 
			     && flag[next.x][next.y] == 0)  {				
				flag[next.x][next.y] = 1;
				queue[tail++] = next;				
			}
		}
		head ++;
	}
	// output
	printf("To get from %s to %s takes %d knight moves.\n", s1, s2, now.step);
}

int main(int argc, char *argv[])
{
	while (scanf("%s%s", s1, s2) != EOF) 
	{
		sx = s1[0] - 'a' + 1;
		sy = s1[1] - '0';
		ex = s2[0] - 'a' + 1;
		ey = s2[1] - '0';
		// width/depth first search
		wfs();
	}
	return 0;
}
